package com.shop.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class BaseDAO {
    // 数据库连接信息
    private static final String URL = "jdbc:mysql://localhost:3306/Shop_DB";
    private static final String USER = "root";
    private static final String PWD = "root"; // 替换为你的MySQL密码

    // 加载驱动
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    // 获取连接
    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection(URL, USER, PWD);
    }
}